﻿///////////////////////////////////////////////////////////////
//                                                           //
// Code from Arcanea Project.                                //
//                                                           //
// Please include this license part to every reproduction    //
//   of code.                                                //
//                                                           //
// This code is under Ms-RL license                          //
//                                                           //
// Please read futher information about the license,         //
//   the project (news and updates) and the                  //
//   contributors on the address :                           //
//     http://www.codeplex.com/Arcanea/                      //
//                                                           //
///////////////////////////////////////////////////////////////
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
//using System.Linq;
using System.Text;
using System.Windows.Forms;
using Arcanea.Mediator.XmlClasses;

namespace Arcanea.PacketEditor
{
    public partial class PacketForm : Form
    {
        private XmlPacket paquet = null;
        public XmlPacket Paquet
        {
            get
            {
                return paquet;
            }
            set
            {
                paquet = value;
                textBoxName.Text = paquet.Name;
                textBoxComment.Text = paquet.Description;
                checkBoxReseau.Checked = paquet.EstUneTrameReseau;
                checkBoxBase.Checked = paquet.ChargerEnBase;
            }
        }

        public PacketForm()
        {
            InitializeComponent();
        }

        private void buttonValider_Click(object sender, EventArgs e)
        {

            if (paquet == null)
            {
                paquet = new XmlPacket();
            }
                paquet.Name = textBoxName.Text.ToLower();
                paquet.Description = textBoxComment.Text;
                paquet.EstUneTrameReseau = checkBoxReseau.Checked;
                paquet.ChargerEnBase = checkBoxBase.Checked;

                if (!(checkBoxReseau.Checked || checkBoxBase.Checked))
                {
                    //Ce n est pas en base ni une trame reseau
                    MessageBox.Show(this, "Choisissez 'une trame reseau' et/ou 'table Sql'");
                }
                else 
                {
                    this.DialogResult = DialogResult.OK;
                    this.Close();
                }
        }

        private void buttonAnnuler_Click(object sender, EventArgs e)
        {
            paquet = null;
            this.Close();
        }

    }
}
